(fix) Inconsistent file path behaviour #53
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Key Changes:
Updated shared validation functions (filename.go):
IsValidFile(), IsValidPath(), and IsValidDir() now accept paths with or without leading / Both /file.txt and file.txt are treated as equivalent paths relative to the mount point Relative paths with .. are still rejected by fs.ValidPath() Both filesystems now behave identically:
S3 filesystem (stream): Already had path normalization in s3Key() that strips leading / Local filesystem (lfs): Uses trim() function to normalize paths before filesystem operations Both accept the same path formats and treat them consistently Updated documentation:
Both Create() and Open() methods in both filesystems now document that paths can be with or without leading / Clear that both forms are treated as paths relative to the mount point Behavior:
Before:
Paths required leading / → fsys.Create("/file.txt", nil) ✅ Paths without / failed → fsys.Create("file.txt", nil) ❌ After:
Both forms work equally → fsys.Create("/file.txt", nil) ✅ → fsys.Create("file.txt", nil) ✅
Both are treated as the same file at the mount root No support for relative traversal with ../ (correctly rejected)